home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bbtinitf.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-01-12  |  3.6 KB  |  110 lines

  1. (*===========================================================================*)
  2. (* Initialize TNC with file                                                  *)
  3. (*                                                                           *)
  4. (*   Copyright 1988, 1989, 1990, 1991 by H. Roy Engehausen.  All rights      *)
  5. (*   reserved.                                                               *)
  6. (*                                                                           *)
  7. (*   This software may be freely distributed and used, but it may not        *)
  8. (*   under any circumstances be sold by anyone other than the author.        *)
  9. (*   It may be distributed by a commercial company as long as it is          *)
  10. (*   for no cost.                                                            *)
  11. (*                                                                           *)
  12. (*===========================================================================*)
  13.  
  14. {$UNDEF DEBUG_MODEM}
  15.  
  16. (*===========================================================================*)
  17. (* Initialize tnc with file                                                  *)
  18. (*===========================================================================*)
  19.  
  20. PROCEDURE t_file_init;
  21.  
  22.   VAR
  23.     f  : TEXT;
  24.     i  : INTEGER;
  25.  
  26.   BEGIN;
  27.  
  28.     {$IFDEF DEBUG_MODEM}
  29.       WRITELN('Start of file read');
  30.     {$ENDIF}
  31.  
  32.     WITH active_port^, active_tcb^ DO
  33.       BEGIN;
  34.  
  35.         (*-------------------------------------------------------------------*)
  36.         (* Set for the unproto channel                                       *)
  37.         (*-------------------------------------------------------------------*)
  38.  
  39.         IF port_type <> port_modem THEN
  40.           BEGIN;
  41.             channel     := 0;
  42.             port_chan_s := port_char + '0';
  43.           END
  44.         ELSE
  45.           BEGIN;
  46.             channel     := 1;
  47.             port_chan_s := port_char + '1';
  48.           END;
  49.  
  50.         (*-------------------------------------------------------------------*)
  51.         (* Read in first file                                                *)
  52.         (*-------------------------------------------------------------------*)
  53.  
  54.         ASSIGN(f, first_load);
  55.  
  56.         {$I-}
  57.         RESET(f);
  58.         {$I+}
  59.  
  60.         i := IORESULT;
  61.         IF i = 2 THEN
  62.           BEGIN;
  63.             window_write('', '***** Port initialization file (' + first_load
  64.                                                                 + 'is missing');
  65.             EXIT;
  66.           END;
  67.  
  68.         IF i <> 0 THEN
  69.           BEGIN;
  70.             STR(i, t_str);
  71.             window_write('', '***** Port initialization file (' + first_load
  72.                                             + 'is getting IO Error ' + t_str);
  73.             EXIT;
  74.           END;
  75.  
  76.         WHILE NOT EOF(f) DO
  77.           BEGIN;
  78.  
  79.             READLN(f, t_str);
  80.  
  81.             {$IFDEF DEBUG_MODEM}
  82.               WRITELN('Writing data -- ', LENGTH(t_str), ' -- ', t_str);
  83.             {$ENDIF}
  84.  
  85.             IF (LENGTH(t_str) > 1) AND
  86.                                  ((t_str[1] = escape) OR (t_str[2] = '%')) THEN
  87.               BEGIN;
  88.                 t_str := COPY(t_str, 2, 255);
  89.                 cmd_tnc(@t_str, TRUE)
  90.               END
  91.             ELSE
  92.               IF LENGTH(t_str) > 0 THEN
  93.                 BEGIN;
  94.                   send_tnc_data_str(t_str);
  95.                   send_tnc_data_str(cr);
  96.                   send_flush;
  97.                 END;
  98.  
  99.             IF port_type = port_modem THEN
  100.               DELAY(300);
  101.             gc;
  102.  
  103.           END;
  104.  
  105.         CLOSE(f);
  106.  
  107.       END;
  108.  
  109.   END;
  110.